The CanvasRenderingContext2D method getImageData() of the Canvas 2D API returns an ImageData object representing the underlying pixel data for a specified portion of the canvas.
This method is not affected by the canvas's transformation matrix. If the specified rectangle extends outside the bounds of the canvas, the pixels outside the canvas are transparent black in the returned ImageData object.
Note: Image data can be painted onto a canvas using theputImageData() method.
You can find more information about getImageData() and general manipulation of canvas contents in Pixel manipulation with canvas.